package com.bdult.vh.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


@Repository
public class OrderDAO implements CommonDAO {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	public HashMap<String, Object> getCartList(String cstmno) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getCartList", Long.valueOf(cstmno).longValue());
	}
	
	public HashMap<String, Object> getCartOrderList(String cstmno) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getCartOrderList", Long.valueOf(cstmno).longValue());
	}
	
	public HashMap<String, Object> getWishList(String cstmno) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getWishList", Long.valueOf(cstmno).longValue());
	}
	
	public ArrayList<HashMap<String, String>> cartCalc(String cstmno) {
		return (ArrayList<HashMap<String, String>>)sqlSessionTemplate.selectList("cartCalc", Long.valueOf(cstmno).longValue());
	}
	
	public int delCart(HashMap<String, String> map) {
		return sqlSessionTemplate.delete("delCart", map);
	}
	
	public int insertCart(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertCart", paramMap);
	}
	
	public int updateCart(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateCart", paramMap);
	}
	
	public int insertWish(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertWish", paramMap);
	}
	
	public int updateWish(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateWish", paramMap);
	}
	
	public ArrayList<HashMap<String, Object>> myOrderList(String cstmno) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("myOrderList", cstmno);
	}
	
	
	
	
	
	//2014-04-27 김진영과장님 작업
	public HashMap<String, Object> getCouponTotal(String cstmno) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getCouponTotal", Long.valueOf(cstmno).longValue());
	}
	
	public ArrayList<HashMap<String, Object>> getCouponList(Map<String, Object> paramMap) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("getCouponList", paramMap);
	}
	
	
	//###### 2014-04-30 심윤 추가 : 결제관련
	public int insertPay(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertPay", paramMap);
	}
	
	public int insertPayCashReceipt(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertPayCashReceipt", paramMap);
	}
	
	public int insertOrder(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertOrder", paramMap);
	}
	
	public int insertOrderDetail(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertOrderDetail", paramMap);
	}	
	//###### 2014-04-30 심윤 추가 : 결제관련
	
	//###### 2014-04-30 심윤 추가 : 재고관련
	public HashMap<String, Object> getStock(Map<String, Object> paramMap) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getStock", paramMap);
	}
	
	public int insertStock(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertStock", paramMap);
	}
	
	public int updateDlvrsrvSR01(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateDlvrsrvSR01", paramMap);
	}
	
	public int updateDlvrsrvSR02(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateDlvrsrvSR02", paramMap);
	}
	
	public int updateDlvrsrvSR03(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateDlvrsrvSR03", paramMap);
	}
	
	public int updateDlvrsrvSR04(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateDlvrsrvSR04", paramMap);
	}
	
	public int updateDlvrsrvSR05(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateDlvrsrvSR05", paramMap);
	}
	
	public int updateSaleState(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateSaleState", paramMap);
	}
	
	public HashMap<String, Object> getOnSaleState(String PRDCD) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getOnSaleState", PRDCD);
	}
	
	public HashMap<String, Object> getSaleState(String PRDCD) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getSaleState", PRDCD);
	}
	
	public int updateSaleStatePdt(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateSaleStatePdt", paramMap);
	}
	//###### 2014-04-30 심윤 추가 : 재고관련
	
	//###### 2014-04-30 심윤 추가 : 쿠폰관련	
	public HashMap<String, Object> getCouponType(String CPNID) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectList("getCouponType", CPNID);
	}
	
	public ArrayList<HashMap<String, Object>> getCouponApply23478(HashMap<String, Object> htData) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("getCouponApply23478", htData);
	}
	
	public ArrayList<HashMap<String, Object>> getCouponApply56111213(HashMap<String, Object> htData) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("getCouponApply56111213", htData);
	}
	
	public int insertCouponUsed(Map<String, Object> paramMap) {
		return sqlSessionTemplate.insert("insertCouponUsed", paramMap);
	}
	
	public int updateUseCoupon(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateUseCoupon", paramMap);
	}
	//###### 2014-04-30 심윤 추가 : 쿠폰관련
	
	//###### 2014-04-30 심윤 추가 : 적립금관련
	public HashMap<String, Object> getPointAcc(String CSTMGR) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getPointAcc", CSTMGR);
	}
	
	public int updateUsePoint(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateUsePoint", paramMap);
	}
	
	public ArrayList<HashMap<String, Object>> getOrderDetail(String ORDNO) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectOne("getOrderDetail", ORDNO);
	}
	
	public int updateOrderDetail(Map<String, Object> paramMap) {
		return sqlSessionTemplate.update("updateOrderDetail", paramMap);
	}
	//###### 2014-04-30 심윤 추가 : 적립금관련
	
	//###### 2014-05-01 심윤 추가 : 주문서 과거배송지
	public HashMap<String, Object> getAddressPastOrder(String CSTMNO) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getAddressPastOrder", CSTMNO);
	}
	//###### 2014-05-01 심윤 추가 : 주문서 과거배송지련
	
	
	//###### 2014-05-01 심윤 추가 : 우편번호
	public ArrayList<HashMap<String,String>> selectZipcodeList(String DONG) {
		return (ArrayList<HashMap<String,String>>)sqlSessionTemplate.selectList("selectZipcodeList", DONG);
	}
	//###### 2014-05-01 심윤 추가 : 우편번호
	
	
	//###### 2014-05-01 심윤 추가 : 주문완료
	public HashMap<String,String> selectOrderComplete(String ORDNO) {
		return (HashMap<String,String>)sqlSessionTemplate.selectOne("selectOrderComplete", ORDNO);
	}
	//###### 2014-05-01 심윤 추가 : 주문완료
	
	
	//###### 2014-05-03 심윤 추가 : 주문관련
	public ArrayList<HashMap<String, Object>> selectOrderCart(Map<String, Object> paramMap) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("selectOrderCart", paramMap);
	}
	
	public ArrayList<HashMap<String, Object>> selectOrderGiftCoupon(int PURRSTCPRC) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("selectOrderGiftCoupon", PURRSTCPRC);
	}
	
	public ArrayList<HashMap<String, Object>> getOrderCardSale(Map<String, Object> paramMap) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("getOrderCardSale", paramMap);
	}
	//###### 2014-05-03 심윤 추가 : 주문관련
	
	public HashMap<String, Object> getOrderSingle(String ORDNO) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getOrderSingle", ORDNO);
	}
	
	public ArrayList<HashMap<String, Object>> getMyOrderSingle(Map<String, Object> paramMap) {
		return (ArrayList<HashMap<String, Object>>)sqlSessionTemplate.selectList("getMyOrderSingle", paramMap);
	}
	
	public String getAccNoYn(String ORDNO) {
		return (String)sqlSessionTemplate.selectOne("getAccNoYn", ORDNO);
	}
	
	public HashMap<String, Object> getApprvCancelPrc(String ORDNO) {
		return (HashMap<String, Object>)sqlSessionTemplate.selectOne("getApprvCancelPrc", ORDNO);
	}	
	
}
